package com.spvs.approval.domain;

/**
 * @Author: 强锡武
 * @CreateTime: 2024-06-23
 * @Description: 审批业务类型枚举类
 * @Version: 1.0
 */
public enum ApprovalType {
    PROCUREMENT("01", "采购"),
    ARRIVAL_ACCEPTANCE("02", "到货验收"),
    INSTALLATION_ACCEPTANCE("03", "安装验收"),
    TECHNICAL_SERVICE("04", "技术规格书"),
    EQUIPMENT_LEASE("05", "设备租赁"),
    EQUIPMENT_RETURN("06", "设备退租"),
    EQUIPMENT_SUSPENSION("07", "设备停租"),
    EQUIPMENT_RENEWAL("08", "设备续租");

    private final String code;
    private final String description;

    ApprovalType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ApprovalType fromCode(String code) {
        for (ApprovalType type : ApprovalType.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;  // 如果没有找到匹配的代码，则返回null
    }

    public static String getDescriptionByCode(String code) {
        for (ApprovalType type : ApprovalType.values()) {
            if (type.getCode().equals(code)) {
                return type.getDescription();
            }
        }
        return null; // 如果没有找到匹配的代码，则返回null
    }
}

